package cn.zhaoyuening.schoolmates.web.general;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.zhaoyuening.schoolmates.domain.Photo;
import cn.zhaoyuening.schoolmates.service.PhotoService;
import cn.zhaoyuening.schoolmates.utils.JsonUtils;

@RestController
public class PhotoController {
	@Autowired
	private PhotoService photoService;
	
	@RequestMapping(value="photo",method=RequestMethod.GET)
	public String findByPhotos(@RequestParam(defaultValue="desc") String order,Long photosId,Integer offset, Integer limit){
		List<Photo> list = photoService.findByPhotosId(photosId, offset, limit,"id"+order);
		String json = JsonUtils.objectToJson(list);
		return json;
	}
}
